<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    button {
      margin: 15px;
    }
    .active {
      background-color: #56a5f1;
      color: #fff;
    }
    .disable {
      cursor: not-allowed;
    }
  </style>
</head>
<body>
  <div id="app">
    <!-- 上一页的判断 -->
    <button :class="{disable:currentPage == 1}" @click="change('pre')">&lt;</button>
    <!-- 页码，判断当前活动页 -->
    <button @click="change(num)" :class="{active:num==currentPage}" v-for="num in 5">{{num}}</button>
    <!-- 下一页的判断 -->
    <button :class="{disable:currentPage == 5}" @click="change('next')">&gt;</button>
  </div>
  <script src="./vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        // 当前页码
        currentPage: 3
      },
      methods: {
        change(page) {
          // 上一页
          if(page === 'pre'){
            if(this.currentPage>1) {
              this.currentPage --;
            }
          } else if(page === 'next'){
          // 下一页
            if(this.currentPage<5) {
              this.currentPage ++;
            }
          }else{
            // 点击的是页码
            this.currentPage = page
          }
        }
      },
    })
  </script>
</body>
</html>